Repository navigation
feat(shader): implement s_swappc_b64 null, long branches and dword jump tables - #754
Merged
oneandonlydean merged 1 commit intoOct 5, 2026
Conversation
…mp tables SOP1 opcode 33 with SDST null keeps no return address, so it is exactly s_setpc_b64; the decoder now reads it that way, as KytyPS5 does. A call with a real destination still throws "unsupported SOP1 opcode 33". GraphBuilder resolves two more jump shapes. A long branch is s_getpc_b64 and s_add_u32/s_addc_u32 or s_sub_u32/s_subb_u32 immediates, also through vcc, all in one block. A dword jump table branches to the table base minus an entry that s_load_dword reads at an index bounded by s_min_u32 and scaled by 4; the resolver follows register writes back through straight-line code, and anything else is still refused. The code table load now also handles one-dword entries. agc_shader_control_flow checks the decode, the graphs and the refusals; the new agc_driver_scalar_swappc runs all shapes on the GPU.
Celegans12
force-pushed
the
feat/shader-swappc-null-setpc
branch
from
October 5, 2026 20:41
65db9a4 to
41fc6c6
Compare
ebosido444-ai
added a commit
to ebosido444-ai/AnyPS5
that referenced
this pull request
Oct 7, 2026
Decodes SOP1 0x21 s_swappc_b64 with a real link pair and translates the call: the fetch-shader call at a VS/ES/LS entry is inlined from the parsed fetch-shader plan, and static in-shader call regions lift through the existing s_setpc_b64 return path. boykopovar#754 covers s_swappc null, long branches and jump tables and leaves a real destination (a call) throwing; this fills exactly that gap and makes fetch-shader-entry shaders recompile. Computed targets, link escapes beyond the constant-offset model, unclosable call/return pairing and recursion throw; see docs/dev/TechnicalDebt.md.
ebosido444-ai
added a commit
to ebosido444-ai/AnyPS5
that referenced
this pull request
Oct 7, 2026
Decodes SOP1 0x21 s_swappc_b64 with a real link pair and translates the call: the fetch-shader call at a VS/ES/LS entry is inlined from the parsed fetch-shader plan, and static in-shader call regions lift through the existing s_setpc_b64 return path. boykopovar#754 covers s_swappc null, long branches and jump tables and leaves a real destination (a call) throwing; this fills exactly that gap and makes fetch-shader-entry shaders recompile. Computed targets, link escapes beyond the constant-offset model, unclosable call/return pairing and recursion throw; see docs/dev/TechnicalDebt.md.
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The decoder threw
unsupported SOP1 opcode 33ons_swappc_b64 null, s[N:N+1](0xbefd21NN), andGraphBuildercould not resolve the jumps built around it.s_setpc_b64: S_SWAPPC_B64 isD.u64 = PC + 4; PC = S0.u64(RDNA2 ISA) and null drops the write, as in KytyPS5DecodeSop1. A real destination (a call) still throws.s_getpc_b64, thens_add_u32/s_addc_u32ors_sub_u32/s_subb_u32immediates on the same pair (alsovcc); the target is the exact 64-bit result, and a jump into the sequence throws.s_load_dwordentry, with the base froms_getpc_b64/s_add_u32/s_addc_u32 0and the index bounded bys_min_u32(at most 255) and scaled bys_lshl_b32 2. The resolver follows the last write of each register through straight-line code, so other code may sit between the steps; anything else is refused. Lowered like the 64-bit tables of feat(shader): lower bounded PC-relative jump tables #141; the code table load now also takes one-dword entries.all_shaders.xpps: 6 long branches and 25 tables in 11 programs, e.g.32ac8b907b12797b0x144beea1f00 806aff6a 0002ee98 826b806b befd216a,2bb3e36a02c363730x208 (15 entries,v_cmpwrites between load and jump),22cccef7ba6022870x67ec (index invcc_lo, load offset 0x50).s_swappc_b64 null, s[6:7](0xbefd2106), whereDecodeRdnaFrontProgramnow stops.resolveJumpTable(waitcnt variants); this PR does not touch that function and merges cleanly with it.s_bfe_i64to the same decoder file; the two merge cleanly.Tested
main681f83e: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)agc_shader_control_flow(decode, front program, table values and targets, both long branches, structurize and recompile, 8 refusals) and newagc_driver_scalar_swappc(all four shapes on the GPU, wave32 and wave64). Both fail onmainwithunsupported SOP1 opcode 33.3ba7ffa5ac5a098apassesspirv-valwith null descriptors.cd88a1ad0e8964d4(6 tables of 98 entries) spends 25 minutes inStructurizer::Structurize, and32ac8b907b12797b(10 tables) does not finish it in 90 minutes.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)